home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / readers / utils / gui4cli / demos / lha.gc < prev    next >
Text File  |  1996-10-28  |  4KB  |  145 lines

  1. G4C
  2.  
  3.  
  4. ; This is a simple GUI for the LHA command, showing you how to use
  5. ; the new commands to dynamically change the GUI
  6. ; LhA is : Copyright (c) 1991,92 by Stefan Boberg.  
  7.  
  8.  
  9. WinBig  400 50 195 100 "LHA Extract"
  10. WinType 11110001
  11.  
  12.  
  13. BOX 0 0 0 0 IN ICONDROP
  14.  
  15.  
  16. ;====================> GENERAL EVENTS
  17.  
  18. xOnLoad
  19. setvar lha_extr   ""        ; Set the default values of our variables
  20. setvar lha_dest   Ram:
  21. setvar lha_pack   ""
  22. setvar lha_darc   Ram:MyArc.lha
  23. setvar lha_com    e
  24. setvar lha_mode   extract
  25. setvar lha_incdir "-r -x"
  26. setgad lha.gc 5 HIDE            ; We open in extract mode, so we dont want this
  27. GuiOpen lha.gc            ; Open the gui
  28.  
  29.  
  30. xOnClose            ; On closing of the window...
  31. guiquit lha.gc            ; we also unload the GUI
  32.  
  33.  
  34.  
  35. ;====================> SOURCE
  36. ; This is where you keep either the archive to extract (lha_extr), or
  37. ; the files to pack (lha_pack)
  38. ; Note we use different requesters according to the mode (lha_mode)
  39.  
  40. TEXT     10 5  80 10 "Archive to extract" 50 NOBOX
  41. gadid 1
  42.  
  43.  
  44. xBUTTON  10 15 20 12 R
  45. if $lha_mode = extract
  46.    ReqFile  -1 -1 300 -40 "Choose archive to unpack" LOAD lha_extr ""
  47.    update lha.gc 2 $lha_extr
  48. else
  49.    ReqFile  -1 -1 300 -40 "Choose file(s) to pack" MULTI lha_pack ""
  50.    update lha.gc 2 $lha_pack
  51. endif
  52.  
  53.  
  54. xTEXTIN 32 15 150 12 "" lha_extr "" 512
  55. gadid 2
  56.  
  57.  
  58. ;====================> DESTINATION
  59. ; Same as above, but for destination directory (lha_dest) or
  60. ; destination archive (lha_darc)
  61.  
  62. TEXT     10 30  80 10 "Destination Directory" 50 NOBOX
  63. gadid 3
  64.  
  65.  
  66. xBUTTON 10 40 20 12 R
  67. if $lha_mode = extract
  68.    ReqFile  -1 -1 300 -40 "Choose Destination dir" DIR lha_dest ""
  69.    update lha.gc 4 $lha_dest
  70. else
  71.    ReqFile  -1 -1 300 -40 "Choose Destination Archive" SAVE lha_darc ""
  72.    update lha.gc 4 $lha_darc
  73. endif
  74.  
  75.  
  76. xTEXTIN 32 40 150 12 "" lha_dest "Ram:" 512
  77. gadid 4
  78.  
  79.  
  80. ;====================> Include DIRECTORIES (Only for packing)
  81. ; This gadget we make appear when lha_mode = pack and
  82. ; disappear when lha_mode = extract (see the cycler below)
  83. ; The -r option instructs lha to recurse (include) subdirectories.
  84. ; The -x option instructs it to keep & use full paths.
  85. ; This is the way I like it.. change it if you don't.
  86.  
  87. xCHECKBOX 151 60 28 12 "Include Dirs" lha_incdir "-r -x" "" ON
  88. gadid 5
  89.  
  90.  
  91. ;====================> Choose MODE (Extract/Pack)
  92. ; This cycler will choose the mode the GUI will work in, which can
  93. ; be the Pack or the Extract mode. According to the mode, we must
  94. ; change the GUI. This is a simple GUI, so the changes are few...
  95. ; NOTE :
  96. ; Herebelow, we use ChangeArg to change the name of the variable
  97. ; that the given xTEXTIN type gadget will store it's value in.
  98. ; (This is just about the most "advanced" thing you can do). 
  99. ; Note that :
  100. ; - We use variable names of the same length.
  101. ; - We ChangeArg BEFORE we update the variables, otherwise the old
  102. ;   variables would be overwritten with the values given.
  103. ; (You probably don't know what I'm talking about, but just keep it
  104. ;  in mind..)
  105.  
  106.  
  107. xCYCLER 10  80 100 14 "" lha_mode
  108. CSTR  Extract  extract
  109. CSTR  Pack     pack
  110. if $lha_mode = extract
  111.    update lha.gc 1 "Archive to Extract :"
  112.    update lha.gc 3 "Destination Directory :"
  113.    changearg lha.gc 2 5 lha_extr
  114.    changearg lha.gc 4 5 lha_dest
  115.    update lha.gc 2 $lha_extr
  116.    update lha.gc 4 $lha_dest
  117.    setgad lha.gc 5 HIDE
  118.    redraw lha.gc
  119.    setwintitle lha.gc "LHA Extract"
  120. else
  121.    update lha.gc 1 "Files to Pack :"
  122.    update lha.gc 3 "Destination Archive :"
  123.    changearg lha.gc 2 5 lha_pack
  124.    changearg lha.gc 4 5 lha_darc
  125.    update lha.gc 2 $lha_pack
  126.    update lha.gc 4 $lha_darc
  127.    setgad lha.gc 5 SHOW
  128.    redraw lha.gc
  129.    setwintitle lha.gc "LHA Pack"
  130. endif
  131.  
  132.  
  133.  
  134. ; According to the mode, run LHA!
  135.  
  136. xBUTTON 115 80 65 14 "Do it!"
  137. if $lha_mode = extract
  138.    cli 'LHA e $lha_extr $lha_dest'
  139. else
  140.    cli 'LHA $lha_incdir a $lha_darc $lha_pack'
  141. endif
  142.  
  143.  
  144.  
  145.